<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BoAnnonceParOrigine
 *
 * @author mssae-9
 */
class BoAnnonceParOrigineCtrl extends jController {
    
    public $pluginParams = array(
                                    
                                    '*'=>array('auth.required'=>true
                                    ),
                                    '*'=>array('jacl2.right'=>'admin.compte.gerer'
                                    )
                            );

    /**
     * Recherche / liste annonce par origine
     * 
     *
     */
    function index() {
         global $gJCoord;
        
        jClasses::inc("annonce~annonceParOrigineSrv");
        jClasses::inc ("commun~CNavBar") ;
        $iCurrentPage						= $gJCoord->request->getParam('iCurrentPage', 1);

        $rep								= $this->getResponse('html');
        $rep->addCSSLink($GLOBALS['gJConfig']->urlengine['basePath'].'design/back/css/jquery-ui.css');
        $rep->addCSSLink($GLOBALS['gJConfig']->urlengine['basePath'].'design/back/css/annonce.css');
        $rep->addJSLink($GLOBALS['gJConfig']->urlengine['basePath'].'design/back/js/annonce.js');
        $rep->addJSLink($GLOBALS['gJConfig']->urlengine['basePath'].'design/back/js/jquery.ui.core.js');
        $rep->menusActifs					= adminHtmlResponse::MENU_ANNONCES ;

        $rep->bodyTpl						= 'annonce~BoAnnonceParOrigine';
        $paramsLeft							= array();
        $paramsRight						= array();
        
        $nbResult							= annonceParOrigineSrv::countAnnonce();
        $annonceParPartenaire				= annonceParOrigineSrv::listAnnoncefromPartenaire();
        if($this->Param('type')){
            if ($iCurrentPage> 1){
                $iDebutListe				= ($iCurrentPage-1) * 20; 
            }else{
                $iDebutListe = 0 ;
            }
            $oNavBar						= new CNavBar (20, 7) ;
            $oNavBar->iCurrPage				= $iCurrentPage;
            $paramsRight['detailAnnonce']	= annonceParOrigineSrv::detailAnnonce($this->stringParam('type'), $this->stringParam('id',''),$iDebutListe,20 );	

            
            $oNavBar->normalizeBar ($paramsRight['detailAnnonce']->nbRes) ;
            $oNavBar->mergeBar ();
        
            $paramsRight['oNavBar']			= $oNavBar;
            
        }
        
        $paramsLeft['nbResult']				= $nbResult;
        $paramsLeft['annonceParPartenaire'] = $annonceParPartenaire;
        $rep->body->assignZone ('oZoneAnnonceOrigineRecheche', 'annonce~BoAnnonceOrigineRecherche',$paramsLeft) ;
        $rep->body->assignZone ('oZoneAnnonceOrigineList', 'annonce~BoAnnonceOrigineList', $paramsRight) ;

        return $rep;
    }
    
}